<template>
  <view class="databoard-table">
    <view class="fee-item">
      <view class="fee-table">
        <view class="tlt">
          <view v-for="item in tableColumn" :key="item">{{ item }}</view>
        </view>
        <view v-for="(item, index) in dataAmount" :key="item.tmpName">
          <view class="fee-first">
            <view style="margin-left: 24rpx">{{ index + 1 }}</view>
            <view style="padding-right: 10rpx">
              <ve-tooltip style="width: 100%">
                <template #content> {{ item.tmpName }} </template>
                <view class="text-ellipsis" style="width: 100%">{{ item.tmpName }}</view>
              </ve-tooltip>
            </view>
            <view>{{ item.sy }}</view>
            <view>{{ item.ddl }}</view>
            <view>{{ item.amount }}</view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>
<script setup>
  import { ref, watch } from 'vue'
  import { numFormatThousands } from '@/vehicle-ui/utils/tools.js'
  import charttips from '../components/charttips.vue'
  const props = defineProps({
    amount: {
      type: Array,
      default: () => [],
    },
    tableColumn: {
      type: Array,
      default: () => [],
    },
    orderNumtableTooltip: {
      type: Object,
      default: () => {},
    },
  })
  const dataAmount = ref([])
  watch(
    () => props.amount,
    (newVal) => {
      let array = []
      if (newVal?.length > 0) {
        array = newVal.map((item) => {
          return Object.assign(
            {
              sy: props.orderNumtableTooltip.name === '车型收益排行' ? numFormatThousands(item.totalAmount) : item.count,
              ddl: props.orderNumtableTooltip.name === '车型收益排行' ? item.count : numFormatThousands(item.totalAmount),
            },
            item,
          )
        })
      }
      dataAmount.value = array
    },
    { immediate: true },
  )
</script>
<style lang="scss" scoped>
  page {
    background: #f7f8fa;
  }
  .flex {
    display: flex;
    justify-content: space-between;
  }
  .fee-item {
    overflow-x: scroll;
    overflow-y: hidden;
    margin-top: 24rpx;
    .fee-table {
      width: 100%;
      .tlt {
        width: 100%;
        height: 88rpx;
        line-height: 88rpx;
        background: #f7f8fa;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        color: #000;
        font-size: 24rpx;
        view:nth-child(1) {
          width: 20%;
          margin-left: 24rpx;
        }
        view:nth-child(2) {
          width: 20%;
        }
        view:nth-child(3) {
          width: 20%;
        }
        view:nth-child(4) {
          width: 20%;
        }
        view:nth-child(5) {
          width: 20%;
        }
      }
      .fee-first {
        width: 100%;
        margin: 32rpx 0 16rpx;
        background: #ffffff;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        color: #191c27;
        font-size: 28rpx;
        view:nth-child(1) {
          width: 20%;
        }
        view:nth-child(2) {
          width: 20%;
        }
        view:nth-child(3) {
          width: 20%;
        }
        view:nth-child(4) {
          width: 20%;
        }
        view:nth-child(5) {
          width: 20%;
        }
      }
    }
  }
  :deep(.ve_tooltip_content) {
    width: 100%;
  }
  .text-ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
</style>
